/*
 ============================================================================
 Name		: playAppView.cpp
 Author	  : CODIO
 Copyright   : CODIO
 Description : Application view implementation
 ============================================================================
 */

// INCLUDE FILES
#include <coemain.h>
#include "playAppView.h"

// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CplayAppView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CplayAppView* CplayAppView::NewL(const TRect& aRect)
	{
	CplayAppView* self = CplayAppView::NewLC(aRect);
	CleanupStack::Pop(self);
	return self;
	}

// -----------------------------------------------------------------------------
// CplayAppView::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CplayAppView* CplayAppView::NewLC(const TRect& aRect)
	{
	CplayAppView* self = new (ELeave) CplayAppView;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	return self;
	}

// -----------------------------------------------------------------------------
// CplayAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CplayAppView::ConstructL(const TRect& aRect)
	{
	// Create a window for this application view
	CreateWindowL();

	// Set the windows size
	SetRect(aRect);
	
	iVideoRect = Rect();
	TPoint point = PositionRelativeToScreen();
	iVideoRect.iTl.iX += point.iX;
	iVideoRect.iTl.iY += point.iY;
	iVideoRect.iBr.iX += point.iX;
	iVideoRect.iBr.iY += point.iY;

	// Activate the window, which makes it ready to be drawn
	ActivateL();
	
	iVideoPlayer = CPlayEngine::NewL(EMdaPriorityNormal,
				EMdaPriorityPreferenceTimeAndQuality, iCoeEnv->WsSession(),
			    *(iCoeEnv->ScreenDevice()), Window(),
				aRect, aRect);
	
	
	}

// -----------------------------------------------------------------------------
// CplayAppView::CplayAppView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CplayAppView::CplayAppView()
	{
	// No implementation required
	}

// -----------------------------------------------------------------------------
// CplayAppView::~CplayAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
CplayAppView::~CplayAppView()
	{
	if (iVideoPlayer)
		{
			delete iVideoPlayer;
			iVideoPlayer = NULL;
		}
	
	}

// -----------------------------------------------------------------------------
// CplayAppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CplayAppView::Draw(const TRect& /*aRect*/) const
	{
	CWindowGc& gc = SystemGc();
    gc.SetBrushColor(KRgbBlack);
	gc.SetBrushStyle (CGraphicsContext::ESolidBrush);
	TRect rect = Rect();
	gc.Clear(rect);
	}

// -----------------------------------------------------------------------------
// CplayAppView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CplayAppView::SizeChanged()
	{
	DrawNow();
	}

// -----------------------------------------------------------------------------
// CplayAppView::HandlePointerEventL()
// Called by framework to handle pointer touch events.
// Note: although this method is compatible with earlier SDKs, 
// it will not be called in SDKs without Touch support.
// -----------------------------------------------------------------------------
//

// End of File
